package com.intranet.fund.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.intranet.fund.dao.BlacklistDao;
import com.intranet.fund.domain.Blacklist;
import com.intranet.sys.domain.User;
import com.water.dao.Page;

@Service
public class BlacklistService {

	@Autowired
	private BlacklistDao blacklistDao;

	
	public Page getAllBlacklist(int pageNo, int pageSize, String param) {
		return blacklistDao.queryBlacklistList(pageNo, pageSize, param);
	}

	public String saveBlacklist(Blacklist blacklist) {
		String msg = "";
		try {
			blacklistDao.save(blacklist);
			msg = "Y";
		} catch (RuntimeException e) {
			msg = e.toString();
		}
		return msg;
	}

	public String updateBlacklist(Blacklist blacklist) {
		String msg = "";
		try {
			blacklistDao.update(blacklist);
			msg = "Y";
		} catch (RuntimeException e) {
			msg = e.toString();
		}
		return msg;
	}

	public String deleteBlacklist(Blacklist blacklist) {
		String msg = "";
		try {
			blacklistDao.remove(blacklist);
			msg = "Y";
		} catch (RuntimeException e) {
			msg = "N";
		}
		return msg;
	}

	public Blacklist getBlacklistById(Integer id) {
		return blacklistDao.get(id);
	}
	
	/**
	 * 登陆用户名查询用户
	 * 
	 * @param username
	 * @return
	 */
	public boolean findBlacklistByIp(String ip) {
		boolean b = false;
		Blacklist bl = blacklistDao.getBlacklistByIp(ip);
		if (bl != null) {
			b = true;
		} else {
			b = false;
		}
		return b;
	}
}
